package com.linq.cool.api.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.linq.cool.common.core.domain.BaseEntity;
import com.linq.cool.common.core.utils.annotation.TreeEntity;
import com.linq.cool.common.core.utils.annotation.TreeField;
import com.linq.cool.common.core.utils.enums.FieldType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yqlin
 * @Date: 2020/12/29 19:19
 * @Description: 部门表
 * @Version: 1.0.0
 */
@EqualsAndHashCode(callSuper = true)
@TreeEntity
@NoArgsConstructor
@AllArgsConstructor
@Data
@Accessors(chain = true)
@TableName(value = "sys_dept")
public class SysDept extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 136548812234948208L;

    @TreeField(fieldType = FieldType.ID)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 父部门id
     */
    @TreeField(fieldType = FieldType.PID)
    @TableField(value = "parent_id")
    private Long parentId;

    /**
     * 祖级列表
     */
    @TableField(value = "ancestor_ids")
    private String ancestorIds;

    /**
     * 部门名称
     */
    @TableField(value = "`name`")
    private String name;

    /**
     * 显示顺序
     */
    @TableField(value = "sort")
    private Integer sort;

    /**
     * 负责人
     */
    @TableField(value = "leader")
    private String leader;

    /**
     * 联系电话
     */
    @TableField(value = "phone")
    private String phone;

    /**
     * 邮箱
     */
    @TableField(value = "email")
    private String email;

    /**
     * 部门状态（0:正常 1:停用）
     */
    @TableField(value = "`status`")
    private Integer status;

    /**
     * 删除标志（0:存在 1:删除）
     */
    @TableLogic
    @TableField(value = "is_deleted")
    private Integer isDeleted;

    /**
     * 父部门名称
     */
    @TableField(exist = false)
    private String parentName;

    /**
     * 子部门
     */
    @TreeField(fieldType = FieldType.CHILD)
    @TableField(exist = false)
    private List<SysDept> children = new ArrayList<SysDept>();

}